#pragma once
#include "stdafx.h"
#include "IParameterChangedListener.h"
#include "EntityControl.h"


class HUD : public IParameterChangedListener
{
private:
	EntityControl* entity;
public:
    HUD()
	{

    }
	void parameterChanged(EntityControl *sourceEntity, std::string parameterName, EntityParameter *oldValue, EntityParameter *newValue)
	{



		//if (sourceEntity->getName() == "Pingvin")
		//{
			if ( parameterName == "hitpoint")
			{
				int hp =((IntEntityParameter*)newValue)->getIntValue();
				refreshHealth(hp);
			}
		//}
	}
	void refreshHealth(int health)
	{
		Ogre::String hp = Ogre::StringConverter::toString(health);
		Ogre::OverlayElement* hpElement = Ogre::OverlayManager::getSingleton().getOverlayElement("Health");
		hpElement->setCaption(hp);
	}
	void setEntity(EntityControl *e)
	{
		entity = e;
		e->subscribeForParameter(HITPOINT_PARAMETER, this);
	}
	void show()
	{
		Ogre::Overlay* mainOverlay = Ogre::OverlayManager::getSingleton().getByName("MainOverlay");
		mainOverlay->show();
	}

	void hide()
	{
		Ogre::Overlay* mainOverlay = Ogre::OverlayManager::getSingleton().getByName("MainOverlay");
		mainOverlay->hide();
	}
};
